Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
  },

  /**
   * 组件的方法列表
   */
  methods: {
    refuse() {
      this.triggerEvent("closeAuth", {}, {});
      wx.showToast({
        title: "不授权无法分享真实信息",
        icon: "none"
      });
    },
    // 获取用户信息
    getUserInfo(e) {
      wx.getSetting({
        success: res => {
          if (res.authSetting["scope.userInfo"]) {
            wx.getUserInfo({
              success: res => {
                console.log(res);   //for debug
                this.triggerEvent("authorized", { data: res }, {});
              },
              fail: err => {
                console.log(err);   //for debug
              }
            });
          } else {
            this.triggerEvent("closeAuth", {}, {});
            wx.showToast({
              title: "不授权无法分享真实信息",
              icon: "none"
            });
          }
        }
      });
    }
  }
});
